package classes.Commands
{
	import components.editor.c_baseEditor;
	import components.editor.c_bitmapElement;
	import components.editor.c_bitmapMaskElement;
	
	import flash.display.DisplayObject;
	import flash.geom.Rectangle;
	
	public class c_assignMaskElement extends c_insertBitmapCommand {
		private var _maskElement: c_bitmapMaskElement;
		private var _params		: Object;
		public function c_assignMaskElement(a_editor:c_baseEditor, a_mask: c_bitmapMaskElement, a_source:DisplayObject, a_params: Object) {
			var _rect: Rectangle = new Rectangle(0, 0, a_source.width, a_source.height);
			super(a_editor, _rect, a_source, false);
			_maskElement = a_mask;
			_params		 = a_params;
		}
		
		override public function Execute():void {
			super.Execute();
			var elemName: String = _params.name;
			var curElement: c_bitmapElement = _maskElement.getElement(elemName)
			if (curElement) curElement.remove();
			
			_maskElement.assignElement(element as c_bitmapElement, _params);
		}		
	}
}